package com.rico.deploy.service.impl;

import com.rico.deploy.entity.User;
import com.rico.deploy.entity.Userlogin;
import com.rico.deploy.mapper.UserMapper;
import com.rico.deploy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author 吴泽胜
 * @FileName UserService
 * @date 2021-04-23 1:15 下午
 * @Software: IntelliJ IDEA
 */
@Service
public class UserServiceimpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User selectUserByUsername(String username) {
        Example example = new Example(User.class);
        example.createCriteria()
                .andEqualTo("username",username);
        return userMapper.selectOneByExample(example);
    }

    //根据角色id查询用户
    @Override
    public List<User> selectRoles(Integer rolesId) {
        Example example = new Example(User.class);
        example.createCriteria()
                .andEqualTo("rolesId",rolesId);
        return userMapper.selectByExample(example);
    }

    @Override
    public User selectUserById(Integer id) {

        return userMapper.selectByPrimaryKey(id);
    }
}
